package ${basePackage}.generator;

import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;

/**
 * <p>Title: </p>
 * <p>Description: 动静态模板代码生成</p>
 *
 * 将 acm-template 整个项目复制到指定的位置，并修改项目中文件的指定内容
 * @author su.gd
 * @date 2023-11-12
 */
public class MainGenerator {

    public static void doGenerator(Object model) throws TemplateException, IOException {
        String inputRootPath = "${fileConfig.inputRootPath}";
        String outputRootPath = "${fileConfig.outputRootPath}";

        String inputPath;
        String outputPath;

        <#list fileConfig.files as fileInfo>
            inputPath = new File(inputRootPath, "${fileInfo.inputPath}").getAbsolutePath();
            outputPath = new File(outputRootPath, "${fileInfo.outputPath}").getAbsolutePath();
            <#if fileInfo.generateType == "static">
                StaticGenerator.copyFilesByHutool(inputPath,  outputPath);
            <#else>
                DynamicGenerator.doGenerate(inputPath, outputPath, model);
            </#if>
        </#list>
    }
}
